package com.sx.pay;

import com.sx.pay.model.PayType;
import com.sx.pay.service.IPayService;
import org.springframework.stereotype.Component;

import java.util.HashMap;
import java.util.Map;

/**
 * @author AdinZ
 * @date 2020/11/7 14:50
 */
public class PayFactory {

    private Map<String, IPayService> map = new HashMap<>();

    public void registered(String appId, IPayService payService) {
        map.put(appId, payService);
    }
    public void registered(IPayService payService) {
        map.put(payService.getAppId(), payService);
    }

    public IPayService getService(String appId) {
        if (!map.containsKey(appId)) throw new RuntimeException("没有开通此支付服务");
        return map.get(appId);
    }

}
